import MarkdownIt from 'markdown-it'
import mk from 'markdown-it-mathjax3'

const md = new MarkdownIt({
  html: true,
  linkify: true,
  typographer: true,
}).use(mk)

const cleanMathStr = (str: string) => {
  return str.replace(/\\\\/g, '\\')
}

export function renderMarkdown(text: string): string {
  const cleaned = cleanMathStr(text || '')
  return md.render(cleaned)
}

export const AllSubjects = ['语文', '数学', '英语', '物理', '化学', '生物', '历史', '地理', '政治']
